<?php $CI =& get_instance()?>
<?php $CI->load->model(array('departemen_model','report_model'))?>
<h2 class="dialog_title"><span>Daftar Perbuatan</span></h2>
<div class="dialog_content" style="padding: 10px 20px; width:700px">
<table width="100%" border="0" cellpadding="5" cellspacing="0">
	<tr>
		<td width="100" align="right" >Periode : </td>
		<td><strong><?php echo $month ?> - <?php echo $year ?></strong></td>
	</tr>
</table>
<?php 
	$data = array();
	//kita load seluruh departemen
	$depData = $CI->departemen_model->select_all('dep_nama asc');
	$depCount = 0;
	$tmp = array();
	foreach($depData->result_array() as $row){
		//kita load rata-rata point tiap departemen
		$tmp[$row['dep_nama']] = $CI->report_model->_rata2PoinDepartemen($row['dep_id'],$month, $month, $year);
		$tmp[$row['dep_nama']] = $tmp[$row['dep_nama']]["$month-$year"];
		$depCount++;
	}
	
	$pointCount=0;
?>
<table class="zebraable" style="border:1px solid #457A3F;" width="100%" border="0" cellpadding="5" cellspacing="0">
  <tr class="header">
  	<td align="left"><span class="colorWhite">No</span></td>
  	<td align="left"><span class="colorWhite">Departemen</span></td>
    <td align="right"><span class="colorWhite">Rata-rata Point</span></td>
  </tr>
  <tbody>
<?php $z=0?>
<?php foreach ($tmp as $row=>$value):?>
    <tr <?php if($z++%2==0): ?>class="zebra"<?php endif?>>
		<td><?php echo $z?></td>
		<td><?php echo $row?></td>
		<td align="right"><?php echo number_format($value,2)?></td>
    </tr>
    <?php $pointCount+=$value?>
<?php endforeach;?>
  </tbody>
	<tr class="header">
		<th align="right" colspan="2"><span class="colorWhite">Rata-rata Point Departemen : </span></th>
		<th align="right"><span class="colorWhite"><?php echo number_format($pointCount,2) ?></span></th>  
	</tr>
	<tr class="header">
		<th align="right" colspan="2"><span class="colorWhite">Jumlah Departemen : </span></th>
		<th align="right"><span class="colorWhite"><?php echo number_format($depCount,2) ?></span></th>  
	</tr>
	<tr class="header">
		<th align="right" colspan="2"><span class="colorWhite">Rata-rata Point Seluruh Departemen : </span></th>
		<th align="right"><span class="colorWhite"><?php echo number_format($pointCount/$depCount,2) ?></span></th>  
	</tr>
</table>
</div>
<div class="dialog_buttons"><input type="button" value="Close" name="close" onclick="FBModal_hide()" /></div>